package com.devenv.common;

/**
 * 错误码枚举
 * 按照产品级标准定义统一错误码
 */
public enum ErrorCode {
    // 通用错误 1000-1999
    SUCCESS(200, "操作成功"),
    SYSTEM_ERROR(1000, "系统内部错误"),
    PARAM_ERROR(1001, "参数错误"),
    NOT_FOUND(1002, "资源不存在"),
    DUPLICATE_ERROR(1003, "资源已存在"),
    OPERATION_FAILED(1004, "操作失败"),
    
    // 认证授权 2000-2999
    UNAUTHORIZED(2000, "未授权"),
    FORBIDDEN(2001, "禁止访问"),
    TOKEN_INVALID(2002, "Token无效"),
    TOKEN_EXPIRED(2003, "Token已过期"),
    LOGIN_FAILED(2004, "登录失败"),
    PASSWORD_ERROR(2005, "密码错误"),
    USER_NOT_EXIST(2006, "用户不存在"),
    USER_DISABLED(2007, "用户已被禁用"),
    
    // 业务错误 3000-3999
    SOFTWARE_NOT_FOUND(3000, "软件不存在"),
    SOFTWARE_NAME_EXISTED(3001, "软件名称已存在"),
    SOFTWARE_VERSION_NOT_FOUND(3002, "软件版本不存在"),
    TEMPLATE_NOT_FOUND(3003, "模板不存在"),
    TEMPLATE_ACCESS_DENIED(3004, "模板访问被拒绝"),
    SCRIPT_GENERATION_FAILED(3005, "脚本生成失败"),
    MIRROR_NOT_AVAILABLE(3006, "镜像源不可用"),
    
    // 文件操作 4000-4999
    FILE_UPLOAD_FAILED(4000, "文件上传失败"),
    FILE_TOO_LARGE(4001, "文件过大"),
    FILE_TYPE_NOT_SUPPORTED(4002, "文件类型不支持"),
    
    // 限流和防护 5000-5999
    RATE_LIMIT_EXCEEDED(5000, "请求过于频繁"),
    CONCURRENT_LIMIT_EXCEEDED(5001, "并发限制"),
    IP_BLOCKED(5002, "IP被封禁");

    private final int code;
    private final String message;

    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
